<?php

namespace App\Admin\Renderable;

use App\Models\User;
use Dcat\Admin\Grid;
use Dcat\Admin\Grid\LazyRenderable;

class UserTable extends LazyRenderable
{
    public function grid(): Grid
    {
        return Grid::make(new User(),function (Grid $grid){

            $grid->model()->with('auth:user_id,name');
            $grid->column('id');
            $grid->column('avatar','头像')->image('',80,80);
            $grid->column('nickname','昵称');
            $grid->column('auth.name','真实姓名');
            $grid->column('phone','手机号');
            $grid->column('created_at');
            $grid->paginate(10);
            $grid->disableActions();
            $grid->showRowSelector();

            $grid->filter(function (Grid\Filter $filter){
                $filter->like('nickname','昵称')->width(3);
                $filter->like('name','真实姓名')->width(3);
                $filter->equal('phone','手机号')->width(3);
            });
        });
    }
}
